/**
 * 
 */
package com.module.bp.event.base;

import com.dalonedrau.jogl.opengl.sprite.SpriteBase;
import com.dalonedrau.vectors.Vector2;
import com.module.bp.bus.BPHexMap;
import com.module.bp.player.BPParty;

/**
 * @author Donald
 */
public final class TeleportPartyEvent extends BaseEvent {
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void setUserInput(final boolean input) { }
	/** flag indicating the event should play an animation. */
	private boolean	animated;
	/** the location to which the party is being teleported. */
	private Vector2	location;
	/**
	 * Creates a new instance of {@link TeleportPartyEvent}.
	 */
	public TeleportPartyEvent() { }
	/**
	 * Creates a new instance of {@link TeleportPartyEvent}.
	 * @param loc the location to which the party is being teleported
	 * @param anim the flag indicating the event should play an animation
	 */
	public TeleportPartyEvent(final int loc, final boolean anim) {
		this(BPHexMap.getInstance().getHexVector(loc), anim);
	}
	/**
	 * Creates a new instance of {@link TeleportPartyEvent}.
	 * @param loc the location to which the party is being teleported
	 * @param anim the flag indicating the event should play an animation
	 */
	public TeleportPartyEvent(final Vector2 loc, final boolean anim) {
		super();
		location = loc;
		animated = anim;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void fire() throws Exception {
		if (super.happens()) {
			BPParty.getInstance().setCurrentHex(location);
			BPParty.getInstance().getWorldMapSprite().getSprite().clearFloatStore();
			if (this.animated) {
				// do something
			}
			super.setFired(true);
			super.setResolved(true);
		} else {
			super.setFired(true);
			super.setResolved(true);
		}
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void setUserInput(int input) {
		// TODO Auto-generated method stub
		
	}
	/**
	 * Sets the flag indicating the event should play an animation.
	 * @param val the flag to set
	 */
	public void setAnimated(final boolean val) {
		animated = val;
	}
	/**
	 * Sets the location to which the party is being teleported.
	 * @param x the x-position to set
	 * @param y the y-position to set
	 */
	public void setLocation(final int x, final int y) {
		if (location == null) {
			location = new Vector2(x, y);
		} else {
			location.set(x, y);
		}
	}
	/**
	 * Sets the location to which the party is being teleported.
	 * @param val the location to set
	 */
	public void setLocation(final Vector2 val) {
		location = val;
	}
}
